<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>志愿者注册</title>
    <link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <style>
        :root {
            --primary: #4A90E2;
            --secondary: #6EC7F2;
            --light: #e6f1ff;
            --dark: #333;
            --shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Nunito', sans-serif;
        }

        body {
            background: linear-gradient(to right bottom, #e0f7fa, #ffffff);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }

        .container {
            max-width: 600px;
            width: 100%;
            background: white;
            border-radius: 16px;
            box-shadow: var(--shadow);
            padding: 40px;
            position: relative;
            z-index: 1;
        }

        .logo {
            text-align: center;
            margin-bottom: 20px;
        }

        .logo i {
            font-size: 60px;
            color: var(--primary);
            background: var(--light);
            width: 100px;
            height: 100px;
            line-height: 100px;
            border-radius: 50%;
            display: inline-block;
        }

        h2 {
            text-align: center;
            color: var(--primary);
            margin-bottom: 10px;
        }

        .subtitle {
            text-align: center;
            color: var(--dark);
            font-size: 14px;
            opacity: 0.7;
            margin-bottom: 30px;
        }

        .form-group {
            margin-bottom: 20px;
            position: relative;
        }

        label {
            display: block;
            margin-bottom: 8px;
            color: var(--dark);
            font-weight: 600;
            font-size: 14px;
        }

        input, select, textarea {
            width: 100%;
            padding: 12px 15px;
            border: 1px solid #ddd;
            border-radius: 8px;
            font-size: 14px;
            transition: all 0.3s ease;
        }

        input:focus,
        select:focus,
        textarea:focus {
            border-color: var(--primary);
            outline: none;
            box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.15);
        }

        .btn-register {
            background: linear-gradient(to right, var(--primary), var(--secondary));
            color: white;
            border: none;
            padding: 14px;
            width: 100%;
            border-radius: 8px;
            font-size: 16px;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.3s ease;
            margin-top: 20px;
        }

        .btn-register:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 16px rgba(74, 144, 226, 0.3);
        }

        .switch-link {
            text-align: center;
            margin-top: 20px;
            font-size: 14px;
        }

        .switch-link a {
            color: var(--primary);
            text-decoration: none;
            font-weight: 600;
        }

        .switch-link a:hover {
            text-decoration: underline;
        }

        .footer {
            margin-top: 30px;
            text-align: center;
            font-size: 13px;
            color: var(--dark);
            opacity: 0.7;
        }

        .footer a {
            color: var(--primary);
            text-decoration: none;
            font-weight: 600;
        }

        .success-message {
            position: fixed;
            top: 30px;
            right: 30px;
            background: #50C878;
            color: white;
            padding: 15px 25px;
            border-radius: 8px;
            box-shadow: var(--shadow);
            z-index: 9999;
            opacity: 0;
            transform: translateY(-20px);
            transition: all 0.4s ease;
            pointer-events: none;
            font-size: 14px;
        }

        .success-message.show {
            opacity: 1;
            transform: translateY(0);
        }
    </style>
</head>
<body>

<div class="success-message" id="successMessage">
    <i class="fas fa-check-circle"></i>
    <span>注册成功！正在跳转...</span>
</div>

<div class="container">

    <div class="logo">
        <i class="fas fa-hands-helping"></i>
    </div>

    <h2 id="formTitle">志愿者注册</h2>
    <p class="subtitle">欢迎您加入我们，用爱心传递温暖，用行动改变世界</p>

    <!-- 志愿者注册表单 -->
    <form id="volunteerForm" action="<c:url value="/users/register"/>" method="post">
        <div class="form-group">
            <label for="usernumber">账号</label>
            <input type="text" id="usernumber" name="usernumber" placeholder="请输入您的账号" required>
        </div>
        <div class="form-group">
            <label for="password">密码</label>
            <input type="password" id="password" name="password" placeholder="请输入您的密码" required>
        </div>
        <div class="form-group">
            <label for="name">姓名</label>
            <input type="text" id="name" name="name" placeholder="请输入您的姓名" required>
        </div>
        <div class="form-group">
            <label for="sex">性别</label>
            <select id="sex" name="sex">
                <option value="男">男</option>
                <option value="女">女</option>
            </select>
        </div>
        <div class="form-group">
            <label for="birthdate">出生日期</label>
            <input type="date" id="birthdate" name="birthdate" required>
        </div>
        <div class="form-group">
            <label for="profession">职业</label>
            <input type="text" id="profession" name="profession" placeholder="请输入您的职业">
        </div>
        <div class="form-group">
            <label for="skills">技能</label>
            <input type="text" id="skills" name="skills" placeholder="请输入您的技能">
        </div>
        <div class="form-group">
            <label for="experience">经历</label>
            <textarea id="experience" name="experience" rows="3" placeholder="请输入您的志愿服务经历"></textarea>
        </div>
        <div class="form-group">
            <label for="phone">联系电话</label>
            <input type="tel" id="phone" name="phone" placeholder="请输入您的电话号码">
        </div>
        <input type="hidden" name="usertype" value="volunteer">
        <button type="submit" class="btn-register">
            <i class="fas fa-sign-in-alt"></i> 注册为志愿者
        </button>
        <div class="switch-link">
            <a href="#" onclick="showOrganizationForm()">注册为组织机构</a>
        </div>
    </form>

    <!-- 组织机构注册表单（默认隐藏） -->
    <form id="organizationForm" action="<c:url value="/users/register"/>" method="post" style="display: none;">
        <div class="form-group">
            <label for="ousernumber">账号</label>
            <input type="text" id="ousernumber" name="usernumber" placeholder="请输入您的账号" required>
        </div>
        <div class="form-group">
            <label for="opassword">密码</label>
            <input type="password" id="opassword" name="password" placeholder="请输入您的密码" required>
        </div>
        <div class="form-group">
            <label for="org_name">机构名称</label>
            <input type="text" id="org_name" name="org_name" placeholder="请输入机构名称" required>
        </div>
        <div class="form-group">
            <label for="org_type">机构类型</label>
            <input type="text" id="org_type" name="org_type" placeholder="例如：NGO、学校、企业等">
        </div>
        <div class="form-group">
            <label for="contact_phone">联系方式</label>
            <input type="tel" id="contact_phone" name="contact_phone" placeholder="请输入联系电话">
        </div>
        <div class="form-group">
            <label for="address">地址</label>
            <input type="text" id="address" name="address" placeholder="请输入机构地址">
        </div>
        <div class="form-group">
            <label for="description">机构简介</label>
            <textarea id="description" name="description" rows="3" placeholder="请简要介绍机构情况"></textarea>
        </div>
        <input type="hidden" name="usertype" value="organization">
        <button type="submit" class="btn-register">
            <i class="fas fa-sign-in-alt"></i> 注册为组织机构
        </button>
        <div class="switch-link">
            <a href="#" onclick="showVolunteerForm()">返回志愿者注册</a>
        </div>
    </form>

    <div class="footer">
        已有账号？<a href="/volunteer/index.jsp">返回登录</a>
    </div>
</div>

<script>
    function showOrganizationForm() {
        document.getElementById('volunteerForm').style.display = 'none';
        document.getElementById('organizationForm').style.display = 'block';
        document.getElementById('formTitle').innerText = '组织机构注册';
    }

    function showVolunteerForm() {
        document.getElementById('organizationForm').style.display = 'none';
        document.getElementById('volunteerForm').style.display = 'block';
        document.getElementById('formTitle').innerText = '志愿者注册';
    }

    // 提交处理 + 成功提示
    document.querySelectorAll("form").forEach(form => {
        form.addEventListener('submit', function(e) {
            e.preventDefault();
            const success = document.getElementById('successMessage');
            success.classList.add('show');
            setTimeout(() => {
                this.submit(); // 实际项目中可替换为 window.location.href
            }, 1500);
        });
    });
</script>

</body>
</html>
